//
//  AppDelegate.swift
//  SwiftProject
//
//  Created by HBY on 2021/4/29.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
//        var tempStr:String = ""
//        var sum = 0
//        let arr:[Int] = [12,23,2,34,45,231,22]
//        for item in arr {
//            tempStr = tempStr+String(item)
//            sum += item
//        }
//        print("结果:\(tempStr)=======\(sum)")
//        
//        let news = arr.map({ (number: Int) -> Int in
//            let result = 1+number
//            return result
//        })
//        print(news)
//        
//        
//        let valueStr = "456"
//        switch valueStr {
//        case "123":
//            print("=====123")
//            break
//        case "345":
//            print("=====345")
//            break
//        case "456":
//            print("=====456")
//            break
//        default:
//            print("other")
//        }
//        
//        MyStruct().printStr()
//        
//        let temp = UserData.shared
//        temp.addObserver(self, forKeyPath: "info", options: [.new,.old], context: nil)
//        temp.show("55")
//        temp.info = "676767"
//        UserData.shared.show("66")
//        UserData.shared.info = "2222222"
//        
//        let user:UserData = UserData(text: "555555")
//        print("------\(user.info ?? "111")")
//        user.addObserver(self, forKeyPath: "info", options: [.new,.old], context: nil)
//        let num:Int = -333
//        print(num)
        
        // Override point for customization after application launch.
        return true
    }
    
    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        print("监听通知!")
    }

    // MARK: UISceneSession Lifecycle

    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }


}

